import React,{useEffect} from 'react'
import {useAppDispatch,useAppSelector} from '@/store/hooks'
import {getMenusAsync,getRoutesAsync} from '@/store/modules/auth'
import {Menu} from 'antd'
import {useNavigate} from 'react-router-dom'
export default function NavigateMenu() {
  const nav=useNavigate()
  const dispatch=useAppDispatch()
  const items=useAppSelector((state)=>{
    return state.auth.menus
    
  })
  useEffect(()=>{
    dispatch(getMenusAsync)
    dispatch(getRoutesAsync)
  },[])
  const go=(arg:any)=>{
    nav(arg.key)
  }
  return (
    <div>
      <Menu
        items={items}
        mode="inline"
        theme="dark"
        onClick={go}>
      </Menu>
    </div>
  )
}
